﻿using Microsoft.EntityFrameworkCore;

namespace SelfService.Model.Models.Auto
{
    public partial class AutoContext : DbContext
    {
        public AutoContext()
        {
        }

        public AutoContext(DbContextOptions<AutoContext> options)
            : base(options)
        {
        }

        public virtual DbSet<AutoPay> AutoPays { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseMySql("server=172.16.99.15;port=3306;user=Auto;password=MSTfA2PTAtDKJ4cG;database=auto", Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.33-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.UseCollation("utf8_general_ci")
                .HasCharSet("utf8");

            modelBuilder.Entity<AutoPay>(entity =>
            {
                entity.ToTable("AutoPay");

                entity.HasComment("支付")
                    .HasCharSet("utf8mb4")
                    .UseCollation("utf8mb4_unicode_ci");

                entity.HasIndex(e => e.CreateTime, "CreateTime");

                entity.HasIndex(e => e.IdCardNo, "IdCardNo");

                entity.HasIndex(e => e.OrderId, "OrderId");

                entity.HasIndex(e => e.PayTime, "PayTime");

                entity.HasIndex(e => e.PayType, "PayType");

                entity.HasIndex(e => e.Status, "Status");

                entity.HasIndex(e => e.TradeNo, "TradeNo");

                entity.HasIndex(e => e.UpdateTime, "UpdateTime");

                entity.Property(e => e.Id)
                    .HasColumnType("int(10) unsigned")
                    .HasComment("ID");

                entity.Property(e => e.Amount)
                    .HasPrecision(10, 2)
                    .HasComment("充值金额");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP")
                    .HasComment("创建时间");

                entity.Property(e => e.HisUserId)
                    .HasMaxLength(10)
                    .HasComment("His用户ID");

                entity.Property(e => e.IdCardNo)
                    .IsRequired()
                    .HasMaxLength(18)
                    .IsFixedLength()
                    .HasComment("身份证号码");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(32)
                    .HasComment("姓名");

                entity.Property(e => e.OrderId)
                    .IsRequired()
                    .HasMaxLength(32)
                    .HasComment("订单ID");

                entity.Property(e => e.PayTime)
                    .HasColumnType("datetime")
                    .HasComment("支付时间");

                entity.Property(e => e.PayType)
                    .HasColumnType("tinyint(4)")
                    .HasComment("支付类型:10=支付宝, 20=微信");

                entity.Property(e => e.Status)
                    .HasColumnType("tinyint(4)")
                    .HasComment("状态:0=待支付, 10=未支付, 20=支付成功, 30=充值成功");

                entity.Property(e => e.TradeNo)
                    .HasMaxLength(128)
                    .HasComment("在线交易流水号");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("CURRENT_TIMESTAMP")
                    .HasComment("更新时间");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
